// pages/records/records.js
const app = getApp();
var formatTime = require("../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    emptyTip: {
      font: "您暂时还没有明细哦~",
      imgUrl: "https://rybc.0791jr.com/WeChat/images/empty-detail.png"
    },
    isNone: false
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    wx.request({
      url: app.baseURL + 'Mine&a=balance',
      data: {
        user_id: app.globalData.userId
      },
      success: (res) => {
        console.log(res);    
        let records = res.data.result;  
        records.forEach((item) => {
          for (let prop in item) { 
            prop == 'time' && (item[prop] = formatTime.formatTime(item.time * 1000));
          }  
        })
        this.setData({
          records: records,
          isNone: !records.length
        })
      }
    })
  }
})